<!DOCTYPE html>
<html lang="en" itemscope itemtype="https://schema.org/WebPage">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Vitess / Sharding in Kubernetes (Tutorial, automated)</title>

        <!-- Webfont -->
    <link href='http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
    
    <!--<link rel="shortcut icon" type="image/png" href="/favicon.png">-->

    <!-- Bootstrap -->
    <link href="/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Styles -->
    <link rel="stylesheet" type="text/css" href="/css/site.css" />
    <!-- Font Awesome icons -->
    <link href="/libs/font-awesome-4.4.0/css/font-awesome.min.css"
          rel="stylesheet"
          type="text/css">
    
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="/libs/bootstrap/js/bootstrap.min.js"></script>


    <!-- metadata -->
    <meta name="og:title" content="Vitess / Sharding in Kubernetes (Tutorial, automated)"/>
    <meta name="og:image" content="/images/vitess_logo_with_border.svg"/>
    <meta name="og:description" content="Vitess is a database clustering system for horizontal scaling of MySQL."/>

    <link rel="icon" href="/images/vitess_logo_icon_size.png" type="image/png">

    
    <script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-60219601-1', 'auto');
  ga('send', 'pageview');
</script>

    
  </head>
  <body class="docs" id="top_of_page">

    <span id="toc-depth" data-toc-depth="h2,h3"></span>


    <nav id="common-nav" class="navbar navbar-fixed-top inverse">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="/">
        <img class="logo" src="/images/vitess_logo_with_border.svg" alt="Vitess">
      </a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="navbar-collapse-1">
      <ul class="nav navbar-nav navbar-right" id="standard-menu-links">
        <li><a href="/overview/">Overview</a></li>
        <li><a href="/user-guide/introduction.html">Guides</a></li>
        <li><a href="/reference/vitess-api.html">Reference</a></li>
        <li><a href="http://blog.vitess.io">Blog</a></li>
        <li><a href="https://github.com/youtube/vitess"><i class="fa fa-github"></i> GitHub</a></li>
        <!-- Hide link to blog unless we have actual posts -->
        <!-- <li><a href="/blog/" title="">Blog</a></li> -->
      </ul>
      <ul class="nav nav-stacked mobile-left-nav-menu" id="collapsed-left-menu">
                <li class="submenu">
          <h4 class="arrow-r no-top-margin">Overview</h4>
          <ul style="display: none">
            <li><a href="/overview/">What is Vitess</a></li>
            <li><a href="/overview/scaling-mysql.html">Scaling MySQL with Vitess</a></li>
            <li><a href="/overview/concepts.html">Key Concepts</a></li>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">Getting Started</h4>
          <ul style="display: none">
            <li style="padding-bottom: 0"><a href="/getting-started/">Run Vitess on Kubernetes</a>
              <ul style="display: block">
                <li style="padding-bottom: 0"><a href="/getting-started/docker-build.html">Custom Docker Build</a></li>
              </ul>
            </li>
            <li><a href="/getting-started/local-instance.html">Run Vitess Locally</a></li>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">User Guide</h4>
          <ul style="display: none">
            <li><a href="/user-guide/introduction.html">Introduction</a>
            <li><a href="/user-guide/client-libraries.html">Client Libraries</a>
            <li><a href="/user-guide/backup-and-restore.html">Backing Up Data</a>
            <li><a href="/user-guide/reparenting.html">Reparenting</a></li>
            <li style="padding-bottom: 0"><a href="/user-guide/schema-management.html">Schema Management</a></li>
              <ul style="display: block">
                <li style="padding-bottom: 0"><a href="/user-guide/vschema.html">VSchema Guide</a></li>
                <li style="padding-bottom: 0"><a href="/user-guide/schema-swap.html">Schema Swap (Tutorial)</a></li>
              </ul>
            <li style="padding-bottom: 0"><a href="/user-guide/sharding.html">Sharding</a>
              <ul style="display: block">
                <li><a href="/user-guide/horizontal-sharding-workflow.html">Horizontal Sharding (Tutorial, automated)</a></li>
                <li><a href="/user-guide/horizontal-sharding.html">Horizontal Sharding (Tutorial, manual)</a></li>
                <li><a href="/user-guide/sharding-kubernetes-workflow.html">Sharding in Kubernetes (Tutorial, automated)</a></li>
                <li style="padding-bottom: 0"><a href="/user-guide/sharding-kubernetes.html">Sharding in Kubernetes (Tutorial, manual)</a></li>
              </ul>
            </li>
            <li><a href="/user-guide/vitess-sequences.html">Vitess Sequences</a></li>
            <li><a href="/user-guide/mysql-server-protocol.html">MySQL Server Protocol</a></li>
            <li><a href="/user-guide/vitess-replication.html">Vitess and Replication</a></li>
            <li><a href="/user-guide/update-stream.html">Update Stream</a></li>
            <li><a href="/user-guide/row-based-replication.html">Row Based Replication</a></li>
            <li><a href="/user-guide/topology-service.html">Topology Service</a></li>
            <li><a href="/user-guide/transport-security-model.html">Transport Security Model</a></li>
            <li style="padding-bottom: 0"><a href="/user-guide/launching.html">Launching</a>
              <ul style="display: block">
                <li><a href="/user-guide/scalability-philosophy.html">Scalability Philosophy</a></li>
                <li><a href="/user-guide/production-planning.html">Production Planning</a></li>
                <li><a href="/user-guide/server-configuration.html">Server Configuration</a></li>
                <li><a href="/user-guide/twopc.html">2PC Guide</a></li>
                <li style="padding-bottom: 0"><a href="/user-guide/troubleshooting.html">Troubleshooting</a></li>
              </ul>
            </li>
            <li><a href="/user-guide/upgrading.html">Upgrading</a></li>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">Reference Guides</h4>
          <ul style="display: none">
            <li><a href="/reference/vitess-api.html">Vitess API</a>
            <li><a href="/reference/vtctl.html">vtctl Commands</a>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">Other Resources</h4>
          <ul style="display: none">
            <li><a href="/resources/presentations.html">Presentations</a>
            <li><a href="http://blog.vitess.io/">Blog</a>
            <li><a href="/resources/roadmap.html">Roadmap</a>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">Contributing</h4>
          <ul style="display: none">
            <li><a href="/contributing/">Contributing to Vitess</a>
            <li><a href="/contributing/github-workflow.html">GitHub Workflow</a>
            <li><a href="/contributing/code-reviews.html">Code Reviews</a>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">Internal</h4>
          <ul style="display: none">
            <li><a href="/internal/">Overview</a>
            <li><a href="/internal/release-instructions.html">Release Instructions</a>
            <li><a href="/internal/publish-website.html">Publish Website</a>
          </ul>
        </li>

        <div>
          <form method="get" action="/search/">
            <input id="search-form" name="q" type="text" placeholder="Search">
          </form>
        </div>

        <li><a href="https://github.com/youtube/vitess" id="collapsed-left-menu-repo-link"><i class="fa fa-github"></i> GitHub</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

    
<div id="masthead">
  <div class="container">
    <div class="row">
      <div class="col-md-9">
        <h1>Sharding in Kubernetes (Tutorial, automated)</h1>
      </div>
    </div>
  </div>
</div>


<div class="container">
    <div class="row scroll-margin" id="toc-content-row">
    <div class="col-md-2" id="leftCol">
      <ul class="nav nav-stacked mobile-left-nav-menu" id="sidebar">
                <li class="submenu">
          <h4 class="arrow-r no-top-margin">Overview</h4>
          <ul style="display: none">
            <li><a href="/overview/">What is Vitess</a></li>
            <li><a href="/overview/scaling-mysql.html">Scaling MySQL with Vitess</a></li>
            <li><a href="/overview/concepts.html">Key Concepts</a></li>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">Getting Started</h4>
          <ul style="display: none">
            <li style="padding-bottom: 0"><a href="/getting-started/">Run Vitess on Kubernetes</a>
              <ul style="display: block">
                <li style="padding-bottom: 0"><a href="/getting-started/docker-build.html">Custom Docker Build</a></li>
              </ul>
            </li>
            <li><a href="/getting-started/local-instance.html">Run Vitess Locally</a></li>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">User Guide</h4>
          <ul style="display: none">
            <li><a href="/user-guide/introduction.html">Introduction</a>
            <li><a href="/user-guide/client-libraries.html">Client Libraries</a>
            <li><a href="/user-guide/backup-and-restore.html">Backing Up Data</a>
            <li><a href="/user-guide/reparenting.html">Reparenting</a></li>
            <li style="padding-bottom: 0"><a href="/user-guide/schema-management.html">Schema Management</a></li>
              <ul style="display: block">
                <li style="padding-bottom: 0"><a href="/user-guide/vschema.html">VSchema Guide</a></li>
                <li style="padding-bottom: 0"><a href="/user-guide/schema-swap.html">Schema Swap (Tutorial)</a></li>
              </ul>
            <li style="padding-bottom: 0"><a href="/user-guide/sharding.html">Sharding</a>
              <ul style="display: block">
                <li><a href="/user-guide/horizontal-sharding-workflow.html">Horizontal Sharding (Tutorial, automated)</a></li>
                <li><a href="/user-guide/horizontal-sharding.html">Horizontal Sharding (Tutorial, manual)</a></li>
                <li><a href="/user-guide/sharding-kubernetes-workflow.html">Sharding in Kubernetes (Tutorial, automated)</a></li>
                <li style="padding-bottom: 0"><a href="/user-guide/sharding-kubernetes.html">Sharding in Kubernetes (Tutorial, manual)</a></li>
              </ul>
            </li>
            <li><a href="/user-guide/vitess-sequences.html">Vitess Sequences</a></li>
            <li><a href="/user-guide/mysql-server-protocol.html">MySQL Server Protocol</a></li>
            <li><a href="/user-guide/vitess-replication.html">Vitess and Replication</a></li>
            <li><a href="/user-guide/update-stream.html">Update Stream</a></li>
            <li><a href="/user-guide/row-based-replication.html">Row Based Replication</a></li>
            <li><a href="/user-guide/topology-service.html">Topology Service</a></li>
            <li><a href="/user-guide/transport-security-model.html">Transport Security Model</a></li>
            <li style="padding-bottom: 0"><a href="/user-guide/launching.html">Launching</a>
              <ul style="display: block">
                <li><a href="/user-guide/scalability-philosophy.html">Scalability Philosophy</a></li>
                <li><a href="/user-guide/production-planning.html">Production Planning</a></li>
                <li><a href="/user-guide/server-configuration.html">Server Configuration</a></li>
                <li><a href="/user-guide/twopc.html">2PC Guide</a></li>
                <li style="padding-bottom: 0"><a href="/user-guide/troubleshooting.html">Troubleshooting</a></li>
              </ul>
            </li>
            <li><a href="/user-guide/upgrading.html">Upgrading</a></li>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">Reference Guides</h4>
          <ul style="display: none">
            <li><a href="/reference/vitess-api.html">Vitess API</a>
            <li><a href="/reference/vtctl.html">vtctl Commands</a>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">Other Resources</h4>
          <ul style="display: none">
            <li><a href="/resources/presentations.html">Presentations</a>
            <li><a href="http://blog.vitess.io/">Blog</a>
            <li><a href="/resources/roadmap.html">Roadmap</a>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">Contributing</h4>
          <ul style="display: none">
            <li><a href="/contributing/">Contributing to Vitess</a>
            <li><a href="/contributing/github-workflow.html">GitHub Workflow</a>
            <li><a href="/contributing/code-reviews.html">Code Reviews</a>
          </ul>
        </li>
        <li class="submenu">
          <h4 class="arrow-r">Internal</h4>
          <ul style="display: none">
            <li><a href="/internal/">Overview</a>
            <li><a href="/internal/release-instructions.html">Release Instructions</a>
            <li><a href="/internal/publish-website.html">Publish Website</a>
          </ul>
        </li>

        <div>
          <form method="get" action="/search/">
            <input id="search-form" name="q" type="text" placeholder="Search">
          </form>
        </div>

      </ul>
    </div>
    <div class="col-md-3" id="rightCol">
      <div class="nav nav-stacked" id="tocSidebar">
        <div id="toc"></div>
      </div>
    </div>
    <div class="col-md-7" id="centerCol">
      <div id="centerTextCol">
        <p>This guide shows you an example about how to apply range-based sharding
process in an existing unsharded Vitess <a href="http://vitess.io/overview/concepts.html#keyspace">keyspace</a>
in <a href="http://kubernetes.io/">Kubernetes</a> using the horizontal resharding workflow.
In this example, we will reshard from 1 shard &quot;0&quot; into 2 shards &quot;-80&quot; and &quot;80-&quot;.
We will follow a process similar to the general
<a href="http://vitess.io/user-guide/horizontal-sharding-workflow.html">Horizontal Sharding guide</a>
except that here we&#39;ll give you the commands you&#39;ll need in the kubernetes
environment.</p>

<h2 id="overview">Overview</h2>

<p>The horizontal resharding process overview can be found
<a href="http://vitess.io/user-guide/horizontal-sharding-workflow.html#overview">here</a> </p>

<h2 id="prerequisites">Prerequisites</h2>

<p>You should complete the <a href="http://vitess.io/getting-started/">Getting Started on Kubernetes</a>
guide (please finish all the steps before Try Vitess resharding) and have left
the cluster running. Then, please follow these steps before running the
resharding process:</p>

<ol>
<li><p>Configure sharding information. By running the command below, we tell
Vitess to shard the data using the page column through the provided VSchema.</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh">vitess/examples/kubernetes<span class="nv">$ </span>./kvtctl.sh ApplyVSchema -vschema <span class="s2">&quot;$(cat vschema.json)&quot;</span> test_keyspace
</code></pre></div></li>
<li><p>Bring up tablets for 2 additional shards:  <em>test_keyspace/-80</em> and
<em>test_keyspace/80-</em> (you can learn more about sharding key range
<a href="http://vitess.io/user-guide/sharding.html#key-ranges-and-partitions">here</a>):</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh">vitess/examples/kubernetes<span class="nv">$ </span>./sharded-vttablet-up.sh
</code></pre></div>
<p>Initialize replication by electing the first master for each of the new shards:</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh">vitess/examples/kubernetes<span class="nv">$ </span>./kvtctl.sh InitShardMaster -force test_keyspace/-80 <span class="nb">test</span>-200
vitess/examples/kubernetes<span class="nv">$ </span>./kvtctl.sh InitShardMaster -force test_keyspace/80- <span class="nb">test</span>-300
</code></pre></div>
<p>After this set up, you should see the shards on Dashboard page of vtctld UI
(<a href="http://localhost:8001/api/v1/proxy/namespaces/default/services/vtctld:web">http://localhost:8001/api/v1/proxy/namespaces/default/services/vtctld:web</a>).
There should be 1 serving shard named &quot;0&quot; and 2 non-serving shards named
&quot;-80&quot; and &quot;80-&quot;. Click the shard node, you can inspect all its tablets
information.</p></li>
<li><p>Bring up a <em>vtworker</em> process (a pod in kubernetes) and a <em>vtworker</em> service
which is used by the workflow to connect with the <em>vtworker</em> pod. (The
number of <em>vtworker</em> should be the same of original shards, we start one
vtworker process here since we have only one original shard in this example.)</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh">vitess/examples/kubernetes<span class="nv">$ </span>./vtworker-up.sh
</code></pre></div>
<p>You can check out the external IP for the vtworker service (please take note
of this external IP, it will be used for the vtworker address in creating
the resharding workflow):</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh"><span class="nv">$ </span>kubectl get service vtworker
</code></pre></div>
<p>You can verify this <em>vtworker</em> process set up through http://<EXTERNAL-IP>:15032/Debugging.
It should be pinged successfully. After you ping the vtworker, please click
&quot;Reset Job&quot;. Otherwise, the vtworker is not ready for executing other tasks.</p></li>
</ol>

<h2 id="horizontal-resharding-workflow">Horizontal Resharding Workflow</h2>

<h3 id="create-the-workflow">Create the Workflow</h3>

<p>Using the web vtctld UI to create the workflow is the same with <a href="http://vitess.io/user-guide/horizontal-sharding-workflow.html#create-the-workflow">steps in local
environment</a>
except for filling the &quot;vtworker Addresses&quot; slot. You need to get the external
IP for vtworker service (mentioned in
<a href="sharding-kubernetes-workflow.html#prerequisites">Prerequisites</a>) and use
&lt;EXTERNAL-IP&gt;:15033 as the vtworker addresses.</p>

<p>Another way to start the workflow is through the vtctlclient command:</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh">vitess/examples/kubernetes<span class="nv">$ </span>./kvtctl.sh WorkflowCreate -skip_start<span class="o">=</span><span class="nb">false </span>horizontal_resharding -keyspace<span class="o">=</span>test_keyspace -vtworkers<span class="o">=</span>&lt;EXTERNAL-IP&gt;:15033 -enable_approvals<span class="o">=</span><span class="nb">true</span>
</code></pre></div>
<h3 id="approvals-of-tasks-execution-canary-feature">Approvals of Tasks Execution (Canary feature)</h3>

<p>Please check the content in general 
<a href="http://vitess.io/user-guide/horizontal-sharding-workflow.html#approvals-of-tasks-execution-canary-feature">Horizontal Sharding guide</a></p>

<h3 id="retry">Retry</h3>

<p>Please check the content in general 
<a href="http://vitess.io/user-guide/horizontal-sharding-workflow.html#retry">Horizontal Sharding guide</a></p>

<h3 id="checkpoint-and-recovery">Checkpoint and Recovery</h3>

<p>Please check the content in general 
<a href="http://vitess.io/user-guide/horizontal-sharding-workflow.html#checkpoint-and-recovery">Horizontal Sharding guide</a></p>

<h2 id="verify-results-and-clean-up">Verify Results and Clean up</h2>

<p>After the resharding process, data in the original shard is identically copied
to new shards. Data updates will be visible on the new shards, but not on the
original shard. You should then see in the vtctld UI <em>Dashboard</em> page that shard
<em>0</em> becomes non-serving and shard <em>-80</em> and shard <em>80-</em> are serving shards.
Verify this for yourself: inspect the database content,
then add messages to the guestbook page and inspect again. You can use
http://&lt;EXTERNAL-IP&gt; (EXTERNAL-IP refers to the external IP of the guest book
service) to visit the guestbook webpage in your browser and choose any random
page for inserting information. Details can be found
<a href="http://vitess.io/getting-started/#test-your-cluster-with-a-client-app">here</a>)
You can inspect the database content using the following commands:</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh"><span class="c"># See what&#39;s on shard test_keyspace/0</span>
<span class="c"># (no updates visible since we migrated away from it):</span>
vitess/examples/kubernetes<span class="nv">$ </span>./kvtctl.sh ExecuteFetchAsDba <span class="nb">test</span>-100 <span class="s2">&quot;SELECT * FROM messages&quot;</span>
<span class="c"># See what&#39;s on shard test_keyspace/-80:</span>
vitess/examples/kubernetes<span class="nv">$ </span>./kvtctl.sh ExecuteFetchAsDba <span class="nb">test</span>-200 <span class="s2">&quot;SELECT * FROM messages&quot;</span>
<span class="c"># See what&#39;s on shard test_keyspace/80-:</span>
vitess/examples/kubernetes<span class="nv">$ </span>./kvtctl.sh ExecuteFetchAsDba <span class="nb">test</span>-300 <span class="s2">&quot;SELECT * FROM messages&quot;</span>
</code></pre></div>
<p>You can also checkout the <em>Topology</em> browser on vtctl UI. It shows you the
information of the keyrange of shard and their serving status. Each shard
should look like this</p>

<p><a href="https://cloud.githubusercontent.com/assets/23492389/24313876/072f61e6-109c-11e7-938a-23b8398958aa.png">shard 0</a></p>

<p><a href="https://cloud.githubusercontent.com/assets/23492389/24313813/bd11c824-109b-11e7-83d4-cca3f6093360.png">shard -80</a></p>

<p><a href="https://cloud.githubusercontent.com/assets/23492389/24313743/7f9ae1c4-109b-11e7-997a-774f4f16e473.png">shard 80-</a></p>

<p>After you verify the result, we can remove the
original shard since all traffic is being served from the new shards:</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh">vitess/examples/kubernetes<span class="nv">$ </span>./vttablet-down.sh
</code></pre></div>
<p>Then we can delete the now-empty shard:</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh">vitess/examples/local<span class="nv">$ </span>./kvtctl.sh DeleteShard -recursive test_keyspace/0
</code></pre></div>
<p>You should then see in the vtctld UI <em>Dashboard</em> page that shard <em>0</em> is gone.</p>

<h2 id="tear-down-and-clean-up">Tear down and Clean up</h2>

<p>Since you already cleaned up the tablets from the original unsharded example by
running <code class="prettyprint">./vttablet-down.sh</code>, that step has been replaced with
<code class="prettyprint">./sharded-vttablet-down.sh</code> to clean up the new sharded tablets.</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh">vitess/examples/kubernetes<span class="nv">$ </span>./guestbook-down.sh
vitess/examples/kubernetes<span class="nv">$ </span>./vtworker-down.sh
vitess/examples/kubernetes<span class="nv">$ </span>./vtgate-down.sh
vitess/examples/kubernetes<span class="nv">$ </span>./sharded-vttablet-down.sh
vitess/examples/kubernetes<span class="nv">$ </span>./vtctld-down.sh
vitess/examples/kubernetes<span class="nv">$ </span>./etcd-down.sh
</code></pre></div>
<p>Then tear down the Container Engine cluster itself, which will stop the virtual machines running on Compute Engine:</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh"><span class="nv">$ </span>gcloud container clusters delete example
</code></pre></div>
<p>It&#39;s also a good idea to remove the firewall rules you created, unless you plan to use them again soon:</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh"><span class="nv">$ </span>gcloud compute firewall-rules delete vtctld guestbook
</code></pre></div>
<h2 id="reference">Reference</h2>

<p>You can checkout the old version tutorial <a href="http://vitess.io/user-guide/sharding-kubernetes.html">here</a>.
It walks you through the resharding process by manually executing commands.</p>

<p>For the kubectl command line interface, which helps you interact with the
kubernetes cluster, you can check out more information
<a href="https://kubernetes.io/docs/user-guide/kubectl-overview">here</a>.</p>

<h2 id="troubleshooting">Troubleshooting</h2>

<h3 id="checking-status-of-your-setup">Checking status of your setup.</h3>

<p>To get status of pods and services you&#39;ve setup, you can use the commands
(all pods should be in Running status, guestbook and vtworker services
should have assign external IP):</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh"><span class="nv">$ </span>kubectl get pods
<span class="nv">$ </span>kubectl get services
</code></pre></div>
<h3 id="debugging-pods">Debugging pods.</h3>

<p>If you find out a component (e.g. vttablet, vtgate) doesn&#39;t respond as
expected, you can surface the log using this command (the pod name can be
found out using the command mentioned above):</p>
<div class="highlight"><pre><code class="language-sh" data-lang="sh"><span class="nv">$ </span>kubectl logs &lt;pod name&gt; <span class="o">[</span>-c &lt;container&gt;<span class="o">]</span>
<span class="c">### example</span>
<span class="c"># $ kubectl logs vtworker</span>
<span class="c"># $ kubectl logs vttablet-XXXX -c vttablet</span>
</code></pre></div>
<h3 id="debugging-pending-external-ip-issue">Debugging pending external IP issue.</h3>

<p>If you found that your service has a pending external IP for long time, it
maybe because you&#39;ve reached the limitation of networking resource. Please
go to your project console on gcloud (cloud.google.com), then go to <em>Load
balancing</em> page (you can search &quot;Load balancing&quot; in the search bar to get
to the page) under Networking section. Then, click &quot;advanced menu&quot; for
editing load balancing resources. Check the forwarding rules you have and
delete the unused ones if there are too many.</p>

      </div>
    </div>
  </div>

</div>

    <div class="page-spacer"></div>
    <footer role="contentinfo" id="site-footer">
  <nav role="navigation" class="menu bottom-menu">
    
    <a href="https://groups.google.com/forum/#!forum/vitess" target="_blank">Contact: vitess@googlegroups.com</a>&nbsp;&nbsp;<b>·</b>&nbsp;&nbsp;
    <a href="https://groups.google.com/forum/#!forum/vitess-announce" target="_blank">Announcements</a>&nbsp;&nbsp;<b>·</b>&nbsp;&nbsp;
    &#169; 2017 <a href="/">Vitess</a> powered by <a href="https://developers.google.com/open-source/">Google Inc</a>
  </nav>
</footer>


        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<!--    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>   -->
    <!-- Include all compiled plugins (below), or include individual files as needed -->
<!--
    <script src="/libs/bootstrap/js/bootstrap.min.js"></script>
-->
    <!-- Include the common site javascript -->
    <script src="/js/common.js" type="text/javascript" charset="utf-8"></script>


  </body>
</html>
